﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using ConnectToDatabase.Model;
using System.Runtime.Serialization;


namespace ConnectToDatabase
{
    [Serializable()]
    public class ShowDB:MarshalByRefObject
    {
        SelectDB m_selectDB = new SelectDB();

        #region Show List Loai San Pham
        public void ShowListLoaiSanPham(DataGrid m_dtLoaiSanPham)
        {
            m_dtLoaiSanPham.ItemsSource = m_selectDB.SelectAllLoaiSanPham();

            //List<LoaiSanPham> dsLoaiSP = new List<LoaiSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllLoaiSanPham().Count; i++)
            //{
            //    LoaiSanPham temp = new LoaiSanPham();

            //    temp.MaLoaiSanPham = m_selectDB.SelectAllLoaiSanPham()[i].MaLoaiSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllLoaiSanPham()[i].TenLoaiSanPham.ToString();
            //    temp.TinhTrang = int.Parse(m_selectDB.SelectAllLoaiSanPham()[i].TinhTrang.ToString());
                
            //    dsLoaiSP.Add(temp);
            //}
            //m_dtLoaiSanPham.ItemsSource = dsLoaiSP;
        }

        public void ShowListLoaiSanPham(DataGrid m_dtLoaiSanPham, int TinhTrang)
        {
            m_dtLoaiSanPham.ItemsSource = m_selectDB.SelectAllLoaiSanPham(TinhTrang);

            List<LoaiSanPham> dsLoaiSP = new List<LoaiSanPham>();
            for (int i = 0; i < m_selectDB.SelectAllLoaiSanPham(TinhTrang).Count; i++)
            {
                LoaiSanPham temp = new LoaiSanPham();

                temp.MaLoaiSanPham = m_selectDB.SelectAllLoaiSanPham(TinhTrang)[i].MaLoaiSanPham.ToString();
                temp.TenLoaiSanPham = m_selectDB.SelectAllLoaiSanPham(TinhTrang)[i].TenLoaiSanPham.ToString();
                temp.TinhTrang = int.Parse(m_selectDB.SelectAllLoaiSanPham(TinhTrang)[i].TinhTrang.ToString());

                dsLoaiSP.Add(temp);
            }
            m_dtLoaiSanPham.ItemsSource = dsLoaiSP;
        }
        #endregion

        #region Show Combobox Nha Phan Phoi
        public void ShowComboboxNhaPP(ComboBox cmb, int TinhTrang)
        {
            for(int i=0; i<m_selectDB.SelectAllNhaPhanPhoi(TinhTrang).Count;i++)
            {
                cmb.Items.Add(m_selectDB.SelectAllNhaPhanPhoi(TinhTrang)[i].MaNhaPP.ToString());
            }
        }
        #endregion

        #region Show Combobox Loai San Pham
        public void ShowComboboxLoaiSP(ComboBox cmb, int TinhTrang)
        {
            for (int i = 0; i < m_selectDB.SelectAllLoaiSanPham(TinhTrang).Count; i++)
            {
                cmb.Items.Add(m_selectDB.SelectAllLoaiSanPham(TinhTrang)[i].MaLoaiSanPham.ToString());
            }
        }
        #endregion

        #region Show List Nha Phan Phoi
        public void ShowListNhaPhanPhoi(DataGrid m_dtNhaPhanPhoi)
        {
            m_dtNhaPhanPhoi.ItemsSource = m_selectDB.SelectAllNhaPhanPhoi();

            //List<NhaPhanPhoi> dsNhaPP = new List<NhaPhanPhoi>();
            //for (int i = 0; i < m_selectDB.SelectAllNhaPhanPhoi().Count; i++)
            //{
            //    NhaPhanPhoi temp = new NhaPhanPhoi();

            //    temp.MaNhaPP = m_selectDB.SelectAllNhaPhanPhoi()[i].MaNhaPP.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllNhaPhanPhoi()[i].TenNhaPP.ToString();
            //    temp.TinhTrang = int.Parse(m_selectDB.SelectAllNhaPhanPhoi()[i].TinhTrang.ToString());

            //    dsNhaPP.Add(temp);
            //}
            //m_dtNhaPhanPhoi.ItemsSource = dsNhaPP;
        }

        public void ShowListNhaPhanPhoi(DataGrid m_dtNhaPhanPhoi, int m_iTinhTrang)
        {
            m_dtNhaPhanPhoi.ItemsSource = m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang);

            List<NhaPhanPhoi> dsNhaPP = new List<NhaPhanPhoi>();
            for (int i = 0; i < m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang).Count; i++)
            {
                NhaPhanPhoi temp = new NhaPhanPhoi();

                temp.MaNhaPP = m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang)[i].MaNhaPP.ToString();
                temp.TenNhaPP = m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang)[i].TenNhaPP.ToString();
                temp.TinhTrang = int.Parse(m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang)[i].TinhTrang.ToString());

                dsNhaPP.Add(temp);
            }
            m_dtNhaPhanPhoi.ItemsSource = dsNhaPP;
        }

        public void ShowListNhaPhanPhoi(DataGrid m_dtNhaPhanPhoi, int m_iTinhTrang, int m_iFrom, int m_iTo)
        {
            m_dtNhaPhanPhoi.ItemsSource = m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang);

            List<NhaPhanPhoi> dsNhaPP = new List<NhaPhanPhoi>();
            for (int i = 0; i < m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang).Count; i++)
            {
                NhaPhanPhoi temp = new NhaPhanPhoi();

                temp.MaNhaPP = m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang)[i].MaNhaPP.ToString();
                temp.TenNhaPP = m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang)[i].TenNhaPP.ToString();
                temp.TinhTrang = int.Parse(m_selectDB.SelectAllNhaPhanPhoi(m_iTinhTrang)[i].TinhTrang.ToString());

                dsNhaPP.Add(temp);
            }
            m_dtNhaPhanPhoi.ItemsSource = dsNhaPP.GetRange(m_iFrom, m_iTo - m_iFrom + 1);
        }
        #endregion

        #region Show List Khuyen Mai
        public void ShowListKhuyenMai(DataGrid m_dtKhuyenMai)
        {
            m_dtKhuyenMai.ItemsSource = m_selectDB.SelectAllKhuyenMai();

            //List<KhuyenMai> dsKhuyenMai = new List<KhuyenMai>();
            //for (int i = 0; i < m_selectDB.SelectAllKhuyenMai().Count; i++)
            //{
            //    KhuyenMai temp = new KhuyenMai();

            //    temp.MaKhuyenMai = m_selectDB.SelectAllKhuyenMai()[i].MaKhuyenMai.ToString();
            //    temp.MaDauSanPham = m_selectDB.SelectAllKhuyenMai()[i].MaDauSanPham.ToString();
            //    temp.NoiDungKM = m_selectDB.SelectAllKhuyenMai()[i].NoiDungKM.ToString();
            //    temp.PTGiamGia = int.Parse(m_selectDB.SelectAllKhuyenMai()[i].PTGiamGia.ToString());
            //    temp.NgayBatDau = DateTime.Parse(m_selectDB.SelectAllKhuyenMai()[i].NgayBatDau.ToString());
            //    temp.NgayKetThuc = DateTime.Parse(m_selectDB.SelectAllKhuyenMai()[i].NgayKetThuc.ToString());

            //    dsKhuyenMai.Add(temp);
            //}
            //m_dtKhuyenMai.ItemsSource = dsKhuyenMai;
        }

        public void ShowListKhuyenMai(DataGrid m_dtKhuyenMai, int m_iFrom, int m_iTo)
        {
            m_dtKhuyenMai.ItemsSource = m_selectDB.SelectAllKhuyenMai(m_iFrom, m_iTo);

            //List<KhuyenMai> dsKhuyenMai = new List<KhuyenMai>();
            //for (int i = 0; i < m_iTo - m_iFrom + 1; i++)
            //{
            //    KhuyenMai temp = new KhuyenMai();

            //    temp.MaKhuyenMai = m_selectDB.SelectAllKhuyenMai(m_iFrom, m_iTo)[i].MaKhuyenMai.ToString();
            //    temp.MaDauSanPham = m_selectDB.SelectAllKhuyenMai(m_iFrom, m_iTo)[i].MaDauSanPham.ToString();
            //    temp.NoiDungKM = m_selectDB.SelectAllKhuyenMai(m_iFrom, m_iTo)[i].NoiDungKM.ToString();
            //    temp.PTGiamGia = int.Parse(m_selectDB.SelectAllKhuyenMai(m_iFrom, m_iTo)[i].PTGiamGia.ToString());
            //    temp.NgayBatDau = DateTime.Parse(m_selectDB.SelectAllKhuyenMai(m_iFrom, m_iTo)[i].NgayBatDau.ToString());
            //    temp.NgayKetThuc = DateTime.Parse(m_selectDB.SelectAllKhuyenMai(m_iFrom, m_iTo)[i].NgayKetThuc.ToString());

            //    dsKhuyenMai.Add(temp);
            //}
            //m_dtKhuyenMai.ItemsSource = dsKhuyenMai;
        }
        #endregion

        #region Show Combobox Dau San Pham
        public void ShowDauSP(ComboBox cmb, string m_sMaNhaPP, string m_sMaLoaiSP)
        {
            for (int i = 0; i < m_selectDB.SelectAllDauSanPham(m_sMaLoaiSP,m_sMaNhaPP).Count; i++)
            {
                cmb.Items.Add(m_selectDB.SelectAllDauSanPham(m_sMaLoaiSP, m_sMaNhaPP)[i].ToString());
            }
        }
        #endregion

        #region Show List San Pham
        public void ShowListSanPham(DataGrid m_dtLoaiSanPham)
        {
            m_dtLoaiSanPham.ItemsSource = m_selectDB.SelectAllLoaiSanPham();

            //List<LoaiSanPham> dsLoaiSP = new List<LoaiSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllLoaiSanPham().Count; i++)
            //{
            //    LoaiSanPham temp = new LoaiSanPham();

            //    temp.MaLoaiSanPham = m_selectDB.SelectAllLoaiSanPham()[i].MaLoaiSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllLoaiSanPham()[i].TenLoaiSanPham.ToString();
            //    temp.TinhTrang = int.Parse(m_selectDB.SelectAllLoaiSanPham()[i].TinhTrang.ToString());

            //    dsLoaiSP.Add(temp);
            //}
            //m_dtLoaiSanPham.ItemsSource = dsLoaiSP;
        }
        #endregion


        #region Show List DS San Pham
        public void ShowListDSSanPham(DataGrid m_dtDSSanPham)
        {
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham();

            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham().Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham()[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham()[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham()[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham()[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham()[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham()[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham()[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            //m_dtDSSanPham.ItemsSource = dsDSSanPham;
        }

        public void ShowListDSSanPham_MaSP(DataGrid m_dtDSSanPham, string m_sMaSP)
        {
            List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            DSSanPham temp = new DSSanPham();

            //temp.MaNhomSanPham = m_selectDB.SelectAllDSSanPham_MaNhomSP(m_sMaSP).MaNhomSanPham.ToString();
            //temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_MaNhomSP(m_sMaSP).TenDauSanPham.ToString();
            //temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_MaNhomSP(m_sMaSP).TenLoaiSanPham.ToString();
            //temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_MaNhomSP(m_sMaSP).TenNhaPP.ToString();
            //temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_MaNhomSP(m_sMaSP).GiaBan.ToString());
            //temp.MauSac = m_selectDB.SelectAllDSSanPham_MaNhomSP(m_sMaSP).MauSac.ToString();
            //temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_MaNhomSP(m_sMaSP).KichThuoc.ToString());

            dsDSSanPham.Add(temp);
            m_dtDSSanPham.ItemsSource = dsDSSanPham;
        }

        public void ShowListDSSanPham_LoaiSP(DataGrid m_dtDSSanPham, string m_sLoaiSP)
        {
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP);

            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            //m_dtDSSanPham.ItemsSource = dsDSSanPham;
        }

        public void ShowListDSSanPham_LoaiSP(DataGrid m_dtDSSanPham, string m_sLoaiSP, int m_iFrom, int m_iTo)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_LoaiSP(m_sLoaiSP, m_iFrom, m_iTo);
        }

        public void ShowListDSSanPham_GiaBan(DataGrid m_dtDSSanPham, int m_iGiaBan)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan);
        }

        public void ShowListDSSanPham_GiaBan(DataGrid m_dtDSSanPham, int m_iGiaBan, int m_iFrom, int m_iTo)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_GiaBan(m_iGiaBan, m_iFrom, m_iTo);
        }

        public void ShowListDSSanPham_KichThuoc(DataGrid m_dtDSSanPham, float m_fKichThuoc)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc);
        }

        public void ShowListDSSanPham_KichThuoc(DataGrid m_dtDSSanPham, float m_fKichThuoc, int m_iFrom, int m_iTo)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_KichThuoc(m_fKichThuoc, m_iFrom, m_iTo);
        }

        public void ShowListDSSanPham_TenSP(DataGrid m_dtDSSanPham, string m_sTenSP)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP);
        }

        public void ShowListDSSanPham_TenSP(DataGrid m_dtDSSanPham, string m_sTenSP, int m_iFrom, int m_iTo)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_TenSP(m_sTenSP, m_iFrom, m_iTo);
        }

        public void ShowListDSSanPham_NhaPP(DataGrid m_dtDSSanPham, string m_sNhaPP)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP);
        }

        public void ShowListDSSanPham_NhaPP(DataGrid m_dtDSSanPham, string m_sNhaPP, int m_iFrom, int m_iTo)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_NhaPP(m_sNhaPP, m_iFrom, m_iTo);
        }

        public void ShowListDSSanPham_MauSac(DataGrid m_dtDSSanPham, string m_sMauSac)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac);
        }

        public void ShowListDSSanPham_MauSac(DataGrid m_dtDSSanPham, string m_sMauSac, int m_iFrom, int m_iTo)
        {
            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo).Count; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo)[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham_MauSac(m_sMauSac, m_iFrom, m_iTo);// dsDSSanPham;
        }

        public void ShowListDSSanPham(DataGrid m_dtDSSanPham, int m_iFrom, int m_iTo)
        {
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham(m_iFrom,m_iTo);

            //List<DSSanPham> dsDSSanPham = new List<DSSanPham>();
            //for (int i = 0; i < m_iTo - m_iFrom + 1; i++)
            //{
            //    DSSanPham temp = new DSSanPham();

            //    temp.MaSanPham = m_selectDB.SelectAllDSSanPham(m_iFrom, m_iTo)[i].MaSanPham.ToString();
            //    temp.TenDauSanPham = m_selectDB.SelectAllDSSanPham(m_iFrom, m_iTo)[i].TenDauSanPham.ToString();
            //    temp.TenLoaiSanPham = m_selectDB.SelectAllDSSanPham(m_iFrom, m_iTo)[i].TenLoaiSanPham.ToString();
            //    temp.TenNhaPP = m_selectDB.SelectAllDSSanPham(m_iFrom, m_iTo)[i].TenNhaPP.ToString();
            //    temp.GiaBan = int.Parse(m_selectDB.SelectAllDSSanPham(m_iFrom, m_iTo)[i].GiaBan.ToString());
            //    temp.MauSac = m_selectDB.SelectAllDSSanPham(m_iFrom, m_iTo)[i].MauSac.ToString();
            //    temp.KichThuoc = float.Parse(m_selectDB.SelectAllDSSanPham()[i].KichThuoc.ToString());

            //    dsDSSanPham.Add(temp);
            //}
            //m_dtDSSanPham.ItemsSource = dsDSSanPham;
        }
        #endregion

        #region Show List LoaiNV
        public void ShowListLoaiNhanVien(DataGrid m_dtLoaiNhanVien, int TinhTrang)
        {
            //List<LoaiNhanVien> dsLoaiNhanVien = new List<LoaiNhanVien>();
            //for (int i = 0; i < m_selectDB.SelectAllDSLoaiNV(TinhTrang).Count; i++)
            //{
            //    LoaiNhanVien temp = new LoaiNhanVien();
            //    temp.MaLoaiNhanVien = m_selectDB.SelectAllDSLoaiNV(TinhTrang)[i].MaLoaiNhanVien.ToString();
            //    temp.TenLoaiNhanVien = m_selectDB.SelectAllDSLoaiNV(TinhTrang)[i].TenLoaiNhanVien.ToString();
            //    temp.TinhTrang = Int32.Parse(m_selectDB.SelectAllDSLoaiNV(TinhTrang)[i].TinhTrang.ToString());

            //    dsLoaiNhanVien.Add(temp);
            //}
            m_dtLoaiNhanVien.ItemsSource = m_selectDB.SelectAllDSLoaiNV(TinhTrang);// dsLoaiNhanVien;
        }
        #endregion

        #region Show Combobox Loai Nhan Vien
         public void ShowComboboxLoaiNV(ComboBox cmb, int TinhTrang)
        {
            for(int i=0; i<m_selectDB.SelectAllDSLoaiNV(TinhTrang).Count;i++)
            {
                cmb.Items.Add(m_selectDB.SelectAllDSLoaiNV(TinhTrang)[i].TenLoaiNhanVien.ToString());
            }
        }
        #endregion

        #region Show List Nhan Vien
         public void ShowListNhanVien(DataGrid m_dtNhanVien, int TinhTrang)
         {
             //List<NhanVien> dsNhanVien = new List<NhanVien>();
             //for (int i = 0; i < m_selectDB.SelectAllDSNhanVien(TinhTrang).Count; i++)
             //{
             //    NhanVien temp = new NhanVien();
             //    temp.MaLoaiNhanVien = m_selectDB.SelectAllDSLoaiNV(TinhTrang)[i].MaLoaiNhanVien.ToString();
             //    temp.TenLoaiNhanVien = m_selectDB.SelectAllDSLoaiNV(TinhTrang)[i].TenLoaiNhanVien.ToString();
             //    temp.TinhTrang = Int32.Parse(m_selectDB.SelectAllDSLoaiNV(TinhTrang)[i].TinhTrang.ToString());

             //    dsLoaiNhanVien.Add(temp);
             //}
             m_dtNhanVien.ItemsSource = m_selectDB.SelectAllDSNhanVien(TinhTrang);
         }

        public void ShowListNhanVien(DataGrid m_dtNhanVien)
        {
            m_dtNhanVien.ItemsSource = m_selectDB.SelectAllDSNhanVien();
        }

        public void ShowListNhanVienTheoLoai(DataGrid m_dtNhanVien,string TenLoaiNV)
        {
            string temp;
            temp = m_selectDB.GetMaLoaiNV(TenLoaiNV);
            m_dtNhanVien.ItemsSource = m_selectDB.SelectAllDSTLNhanVien(temp);
        }

        #endregion

        #region Show List San Pham Mua Ban
        public void ShowListSanPhamMuaBan(DataGrid m_dtDSSanPham, int m_iFrom, int m_iTo)
        {
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllSanPhamMuaBan(m_iFrom, m_iTo);
        }

        public void ShowListSanPhamMuaBan_MaSP(DataGrid m_dtDSSanPham, string m_sMaSP)
        {
            //m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllDSSanPham(m_iFrom,m_iTo);

            List<SanPhamMuaBan> dsDSSanPham = new List<SanPhamMuaBan>();

            SanPhamMuaBan temp = new SanPhamMuaBan();

            if (m_selectDB.SelectAllSanPhamMuaBan_MaSP(m_sMaSP) != null)
            {
                //temp.MaSanPham = m_selectDB.SelectAllSanPhamMuaBan_MaSP(m_sMaSP).MaSanPham.ToString();
                //temp.TenDauSanPham = m_selectDB.SelectAllSanPhamMuaBan_MaSP(m_sMaSP).TenDauSanPham.ToString();
                //temp.GiaBan = int.Parse(m_selectDB.SelectAllSanPhamMuaBan_MaSP(m_sMaSP).GiaBan.ToString());

                dsDSSanPham.Add(temp);
                m_dtDSSanPham.ItemsSource = dsDSSanPham;
            }
        }

        public void ShowListSanPhamDaMua(DataGrid m_dtDSSanPham, string m_sMaHoaDon)
        {
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllSanPhamDaMua(m_sMaHoaDon);
        }
        public void ShowListSanPhamDaMua(DataGrid m_dtDSSanPham, string m_sMaHoaDon, string m_sMaSPDaMua)
        {
            //List<SanPhamMuaBan> dsDSSanPham = new List<SanPhamMuaBan>();

            //SanPhamMuaBan temp = new SanPhamMuaBan();
            //temp.MaSanPham = m_selectDB.SelectAllSanPhamDaMua(m_sMaHoaDon, m_sMaSPDaMua).MaSanPham.ToString();
            //temp.TenDauSanPham = m_selectDB.SelectAllSanPhamDaMua(m_sMaHoaDon, m_sMaSPDaMua).TenDauSanPham.ToString();
            //temp.GiaBan = int.Parse(m_selectDB.SelectAllSanPhamDaMua(m_sMaHoaDon, m_sMaSPDaMua).GiaBan.ToString());
            m_dtDSSanPham.ItemsSource = m_selectDB.SelectAllSanPhamDaMua(m_sMaHoaDon, m_sMaSPDaMua);
        }
        #endregion

        #region Show List Phieu Tra
        public void ShowListPhieuTra(DataGrid m_dtPhieuTra)
        {
            m_dtPhieuTra.ItemsSource = m_selectDB.SelectAllPhieuTraSanPhamLoi();
        }
        #endregion

        #region Show List Dau San Pham
        public void ShowListDauSanPham(DataGrid m_dtDauSP, int TinhTrang)
        {

            m_dtDauSP.ItemsSource = m_selectDB.SelectAllDauSanPham(TinhTrang);
        }
        #endregion

        public int Test() { return 0; }
    }
}
